package com.ccsu.eb.config;

import com.ccsu.eb.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // /**拦截controller所有的请求  /user/order 表示拦截该uri
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns(new String[]{"/car/order"});

    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:resources/", "classpath:static/", "classpath:public/",
                        "classpath:META-INF/resources/");
    }
}